package com.hc.conferencecheck.service.impl;

import com.hc.conferencecheck.entity.AttendRecordBranch;
import com.hc.conferencecheck.entity.AttendRecordBranchExample;
import com.hc.conferencecheck.entity.ResultMsg;
import com.hc.conferencecheck.entity.ResultStatusCode;
import com.hc.conferencecheck.mapper.AttendRecordBranchMapper;
import com.hc.conferencecheck.service.AttendRecordBranchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

/**
 * 用户会议分会场的service实现类
 */
@Service
@Transactional
public class AttendRecordBranchServiceImpl implements AttendRecordBranchService {
    private static final Logger logger = LoggerFactory.getLogger(AttendRecordBranchServiceImpl.class);

    @Resource
    private AttendRecordBranchMapper attendRecordBranchMapper;


    /**
     * 修改分会场的签到状态
     */
    public ResultMsg editBranchAddressStatus(Integer recordId, Integer status) {
        AttendRecordBranchExample example = new AttendRecordBranchExample();
        AttendRecordBranchExample.Criteria criteria = example.createCriteria();
        criteria.andIdEqualTo(recordId);

        AttendRecordBranch attendRecordBranch = new AttendRecordBranch();
        attendRecordBranch.setStatus(status.toString());
        int i = attendRecordBranchMapper.updateByExampleSelective(attendRecordBranch, example);

        if (i == 1) {
            return new ResultMsg(ResultStatusCode.OK.getCode(), ResultStatusCode.OK.getMsg(), "修改成功");
        } else {
            logger.error("修改分会场状态失败");
            return new ResultMsg(ResultStatusCode.EORROR.getCode(), ResultStatusCode.EORROR.getMsg(), "修改失败");
        }
    }

}
